﻿using BCCommon.TMS.Driver;
using BCCommon.TMS.LearnTrain;
using BCEntity.TMS.Driver.DriverExamine;
using BCEntity.TMS.LearningTrain.LearnTrainStatistics;
using BCEntity.TMS.LearningTrain.PendingLearningVehicle;
using BCEntity.TMS.LearnTrain;
using BCEntity.TMS.LearnTrain.LearnTrainStatistics;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace BCData.TMS.LearningTrain
{
    public interface IPendingLearningVehicleData
    {
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="pendingLearningVehicleId"></param>
        /// <returns></returns>
        Task<int> DeleteAsync(long pendingLearningVehicleId);
        /// <summary>
        /// 获取单条记录
        /// </summary>
        /// <param name="pendingLearningVehicleId"></param>
        /// <returns></returns>
        Task<PendingLearningVehicleEntity> GetEntityAsync(long pendingLearningVehicleId);
        /// <summary>
        /// 根据司机id获取单条记录
        /// </summary>
        /// <param name="driverId"></param>
        /// <returns></returns>
        Task<PendingLearningVehicleEntity> GetEntityByDriverId(long driverId);
        /// <summary>
        /// 获取列表(分页)
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        Task<(IEnumerable<PendingLearningVehicleEntity>, int)> GetListAsync(int pageIndex, int pageSize);
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<PendingLearningVehicleEntity> InsertAsync(PendingLearningVehicleEntity entity);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<PendingLearningVehicleEntity> UpdateAsync(PendingLearningVehicleEntity entity);
        /// <summary>
        /// 获取待培训列表(分页)
        /// </summary>
        /// <param name="agentRecordId">代理商id</param>
        /// <param name="driverName">司机名称</param>
        /// <param name="vehicleNo">车辆编号</param>
        /// <param name="driverRoleType">司机角色</param>
        /// <param name="isTrainingScheduleRecord">是否安排培训</param>
        /// <param name="notifyStartDate">开始日期</param>
        /// <param name="notifyEndDate">结束日期</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        Task<(IEnumerable<PendingLearningVehicleViewEntity>,int)> Query(long agentRecordId, string driverName, string vehicleNo,
            DriverRoleType? driverRoleType, bool? isTrainingScheduleRecord, DateTime? notifyStartDate, 
            DateTime? notifyEndDate, int pageIndex, int pageSize);
        /// <summary>
        /// 获取当前培训点的人数
        /// </summary>
        /// <param name="vehicleTrainingScheduleRecordId">培训点id</param>
        /// <returns></returns>
        Task<int> GetCount(long vehicleTrainingScheduleRecordId);
        /// <summary>
        /// 获取培训汇总
        /// </summary>
        /// <param name="vehicleTrainingScheduleRecordId">培训记录id</param>
        /// <returns></returns>
        Task<VehicleTrainingScheduleStatisticsEntity> GetTrainingScheduleStatistics(long vehicleTrainingScheduleRecordId);
        /// <summary>
        /// 获取培训记录详情
        /// </summary>
        /// <param name="agentRecordId">代理商id</param>
        /// <param name="vehicleTrainingScheduleRecordId">培训记录id</param>
        /// <param name="phone">手机</param>
        /// <returns></returns>
        Task<IEnumerable<VehicleTrainingScheduleDetailEntity>> GetVehicleTrainingScheduleDetail(long agentRecordId, long vehicleTrainingScheduleRecordId, string phone);
        /// <summary>
        /// 获取列表(不可通用)
        /// </summary>
        /// <param name="pendingLearningVehicleIds">待培训列表id</param>
        /// <returns></returns>
        Task<IEnumerable<PendingLearningVehicleEntity>> GetListByIdsAsync(List<long> pendingLearningVehicleIds);
        /// <summary>
        /// 允许考试
        /// </summary>
        /// <param name="driverIds">司机id</param>
        /// <param name="vehicleTrainingScheduleRecordId">培训安排记录id</param>
        /// <param name="limitDuration">时长</param>
        /// <returns></returns>
        Task<bool> AllowJoinExamAsync(List<long> driverIds, long vehicleTrainingScheduleRecordId, int limitDuration);

        /// <summary>
        /// 获取培训历史记录
        /// </summary>
        /// <param name="agentRecordId">代理商id</param>
        /// <param name="vehicleNo">车牌号</param>
        /// <param name="trainingSiteConfigId">培训点配置id</param>
        /// <param name="trainingStartDate">培训开始日期</param>
        /// <param name="trainingEndDate">培训结束日期</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        Task<(IEnumerable<LearnTrainHistoryRecordEntity>, int)> GetLearnTrainHistoryRecordEntity(long agentRecordId,
            string vehicleNo, long? trainingSiteConfigId, DateTime? trainingStartDate, DateTime? trainingEndDate, int pageIndex, int pageSize);

        #region 进入考场
        /// <summary>
        /// 考试统计
        /// </summary>
        /// <param name="vehicleTrainingScheduleRecordId">培训期数编号</param>
        /// <returns></returns>
        Task<ExaminationStatisticsEntity> GetExaminationStatistics(long? vehicleTrainingScheduleRecordId);
        /// <summary>
        /// 获取最老的考试记录时间
        /// </summary>
        /// <param name="vehicleTrainingScheduleRecordId">培训期数编号</param>
        /// <returns></returns>
        Task<LearnTrainAllowedExaminationRecordEntity> GetLearnTrainAllowedExaminationRecordEntity(long vehicleTrainingScheduleRecordId);
        /// <summary>
        /// 获取累计培训人员
        /// </summary>
        /// <returns></returns>
        Task<ExaminationStatisticsEntity> GetAllTrainCount();
        /// <summary>
        /// 获取考试通过和未通过司机信息
        /// </summary>
        /// <param name="vehicleTrainingScheduleRecordId">培训期数编号</param>
        /// <param name="isLearnTrainPassed">是否通过</param>
        /// <returns></returns>
        Task<IEnumerable<LearnTrainExaminationDriverEntity>> GetExaminationDriverInfo(long vehicleTrainingScheduleRecordId, bool isLearnTrainPassed);

        /// <summary>
        /// 获取考试中司机信息
        /// </summary>
        /// <param name="vehicleTrainingScheduleRecordId">培训期数编号</param>
        /// <returns></returns>
        Task<IEnumerable<LearnTrainExaminationDriverEntity>> GetExaminationHaving(long vehicleTrainingScheduleRecordId);
        /// <summary>
        /// 获取考试成绩
        /// </summary>
        /// <param name="driverId">司机编号</param>
        /// <returns></returns>
        Task<DriverExamineMarkEntity> GetDriverExamine(long driverId);
        /// <summary>
        /// 获取正在考试中
        /// </summary>
        /// <param name="vehicleTrainingScheduleRecordId">培训期数编号</param>
        /// <returns></returns>
        Task<IEnumerable<LearnTrainExaminationDriverEntity>> GetNoExaminationHaving(long vehicleTrainingScheduleRecordId);
        #endregion

        /// <summary>
        /// 获取获取上月以及本月培训人数
        /// </summary>
        /// <param name="agentRecordId">代理商id</param>
        /// <param name="datetime">时间</param>
        /// <param name="LearnTrainEnum">类型</param>
        /// <param name="trainingSiteConfigId">培训点配置id</param>
        /// <returns></returns>
        Task<CommonDriverEntity> GetLearningDriverCount(long? agentRecordId, DateTime? datetime, LearnTrainEnum LearnTrainEnum,
            long? trainingSiteConfigId);
        /// <summary>
        /// 培训考试通过人数统计
        /// </summary>
        /// <param name="agentRecordId"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        Task<IEnumerable<LearnTrainMonthAnalysisEntity>> GetTrainSeheduleAnalysisAsync(long agentRecordId, DateTime date);
        /// <summary>
        /// 考试人数
        /// </summary>
        /// <param name="agentRecordId">代理商id</param>
        /// <param name="datetime">时间</param>
        /// <returns></returns>
        Task<ExamineDriverCountEntity> GetFirstExamDriverCount(long agentRecordId, DateTime? datetime);
        /// <summary>
        /// 累计培训人员
        /// </summary>
        /// <param name="agentRecordId"></param>
        /// <returns></returns>
        Task<IEnumerable<TrainCountEntity>> GetTrainCountDetailList(long agentRecordId);
        /// <summary>
        /// 获取待培训人员
        /// </summary>
        /// <param name="vehicleTrainingScheduleRecordId">培训安排记录id</param>
        /// <returns></returns>
        Task<IEnumerable<PendingLearningVehicleEntity>> GetList(long vehicleTrainingScheduleRecordId);
    }
}